home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / offsetCosPreset.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.1 KB  |  159 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 28, 1997
  22. //  Author:        mpw
  23. //
  24. //  Description:
  25. //      The offsetCosPreset() procedure executes a offset cos operation on 
  26. //      a cos based on the offset option vars.
  27. //
  28. //  Input Arguments:
  29. //      None.
  30. //
  31. //  Return Value:
  32. //      None.
  33. //
  34.  
  35. proc string pieceTogetherOffsetCosCmd(
  36.      int $history,
  37.     int $curvePartial,
  38.     int $connectBreaks,
  39.     int $stitch,
  40.     int $cutLoop,
  41.     float $distance,
  42.     float $tolerance,
  43.     int $subdivisionDensity)
  44. //
  45. //    Description :
  46. //        Piece together a offsetCos command.
  47. //
  48. {
  49.     string $cmd;
  50.     $cmd = "offsetCurveOnSurface ";
  51.  
  52.     // construction history
  53.     $cmd = $cmd + " -ch ";
  54.     if ( $history == 1 ) $cmd = $cmd + "on";
  55.     else  $cmd = $cmd + "off";
  56.     
  57.     // curve range.
  58.     //
  59.     $cmd = $cmd + " -rn " ;
  60.     if( $curvePartial == 1 ) $cmd = $cmd + "true" ;
  61.     else $cmd = $cmd + "false" ;
  62.  
  63.     // connect breaks
  64.     $cmd = $cmd + " -cb " + $connectBreaks;
  65.  
  66.     // stitch
  67.     if ( $stitch == 1 ) $cmd = $cmd + " -st true";
  68.     else $cmd = $cmd + " -st false";
  69.  
  70.     // cut loops
  71.     if ( $cutLoop == 1 ) $cmd = $cmd + " -cl true";
  72.     else $cmd = $cmd + " -cl false";
  73.  
  74.     // offset distance
  75.     $cmd = $cmd + " -d " + $distance;
  76.  
  77.     // offset tolerance
  78.     $cmd = $cmd + " -tol " + $tolerance;
  79.  
  80.     // subdivision density
  81.     $cmd = $cmd + " -sd " + $subdivisionDensity;
  82.  
  83.     return $cmd;
  84. }
  85.  
  86. global proc offsetCosPreset(
  87.      int $history,
  88.     int $curvePartial,
  89.     int $connectBreaks,
  90.     int $stitch,
  91.     int $cutLoop,
  92.     float $distance,
  93.     float $tolerance,
  94.     int $subdivisionDensity)
  95. //
  96. //    offsetCos with the preset options.
  97. //    Use this proc when operation dragged to Shelf.
  98. //
  99. {
  100.     // Get the list of nurbs cos selected. Works for curves on surface
  101.     // Do this here because addViewNormal creates a node which will blow away the
  102.     // selection list
  103.     //
  104.     global int $gSelectNurbsCurvesBit;
  105.     global int $gSelectCurvesOnSurfacesBit;
  106.     global int $gSelectSurfaceEdgeBit;
  107.     global int $gSelectIsoparmsBit;
  108.     string $curvesList[] = `filterExpand -ex true -sm $gSelectCurvesOnSurfacesBit -sm $gSelectSurfaceEdgeBit -sm $gSelectIsoparmsBit`;
  109.  
  110.     // build the command
  111.     string $cmd = pieceTogetherOffsetCosCmd($history,
  112.                                             $curvePartial,
  113.                                             $connectBreaks,
  114.                                             $stitch,
  115.                                             $cutLoop,
  116.                                             $distance,
  117.                                             $tolerance,
  118.                                             $subdivisionDensity);
  119.  
  120.     // placeholder for one selection item
  121.     int $nitems = 1;
  122.     $cmd = appendToCmdPlaceHoldersForSelectionItems( $cmd, $nitems );
  123.  
  124.     int $numCurves = size($curvesList) ;
  125.     if( $numCurves < 1 ) {
  126.         error "Select at least one curve on surface" ; 
  127.     } else {
  128.  
  129.         // compute each offset in turn
  130.         string $offsetResults[];
  131.         string $curve[1];
  132.         for( $i = 0 ; $i < $numCurves ; $i++ ) {
  133.             $curve[0] = $curvesList[$i];
  134.             string $results[] = executeCmdOnItems( $cmd, $curve );    
  135.             $offsetResults = stringArrayCatenate($offsetResults, $results);
  136.         }
  137.  
  138.         // select the results.
  139.         //
  140.  
  141.         int $resultCount = size($offsetResults);
  142.         if ( $resultCount > 0 ) 
  143.         {
  144.             string $selectString;
  145.             $selectString = "select -r ";
  146.             int $i;
  147.             for ( $i = 0; $i < $resultCount; $i++ ) 
  148.             {
  149.                 $selectString +=  $offsetResults[$i];
  150.                 $selectString += " ";
  151.             }
  152.             $selectString += ";";
  153.             select -cl;
  154.             eval($selectString);
  155.  
  156.         }
  157.     }
  158. }
  159.